package org.karelun.ideaboard.edit.ui.cdo.action;

import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
import org.karelun.ideaboard.edit.ui.cdo.ITransactionEditingDomain;

public class CreateChildAction extends org.eclipse.emf.edit.ui.action.CreateChildAction {

	public CreateChildAction(IWorkbenchPart workbenchPart,
			ISelection selection, Object descriptor) {
		super(workbenchPart, selection, descriptor);
	}

	public CreateChildAction(IEditorPart editorPart, ISelection selection,
			Object descriptor) {
		super(editorPart, selection, descriptor);
	}

	public CreateChildAction(ITransactionEditingDomain editingDomain,
			ISelection selection, Object descriptor) {
		super(editingDomain, selection, descriptor);
	}

	@Override
	public void configureAction(ISelection selection) {
		super.configureAction(selection);

		if (isEnabled()) {
			CDOView cdoView = ((ITransactionEditingDomain) editingDomain)
					.getCDOView();
			setEnabled(!cdoView.isClosed() && !cdoView.isReadOnly());
		}
	}

}
